package com.app.micaihu.view.army.dialog

import android.os.Bundle
import android.view.View
import com.app.base.BaseBottomSheetDialogFragment
import com.app.micaihu.R
import com.app.micaihu.configure.Config
import kotlinx.android.synthetic.main.army_member_menu_dialog.*

/**
 * 成员列表 菜单
 */
class ArmyMemberMenuDialog : BaseBottomSheetDialogFragment() {

    override fun getLayoutId() = R.layout.army_member_menu_dialog

    private var onMenuClickListener: OnMenuClickListener? = null
    private var showDel = false
    private var showInviteMicaihu = false
    override fun getBundle(bundle: Bundle) {
        showDel = bundle.getBoolean(Config.Extra.showDel, false)
        showInviteMicaihu = bundle.getBoolean(Config.Extra.showInviteMicaihu, false)
    }

    override fun setData() {
        if (showDel) {
            tvDel.visibility = View.VISIBLE
            viewDelLine.visibility = View.VISIBLE
        } else {
            tvDel.visibility = View.GONE
            viewDelLine.visibility = View.GONE
        }
        if (showInviteMicaihu) {
            tvInvitation.visibility = View.VISIBLE
            viewInvitation.visibility = View.VISIBLE
        } else {
            tvInvitation.visibility = View.GONE
            viewInvitation.visibility = View.GONE
        }
    }

    override fun addListeners() {
        tvInvitation.setOnClickListener { onMenuClickListener?.onInvitationClick() }
        tvShare.setOnClickListener { onMenuClickListener?.onShareClick() }
        tvDel.setOnClickListener { onMenuClickListener?.onDelClick() }
        tvCancel.setOnClickListener { dismiss() }
    }

    interface OnMenuClickListener {
        fun onInvitationClick()
        fun onShareClick()
        fun onDelClick()
    }

    fun setOnMenuClickListener(onMenuClickListener: OnMenuClickListener) {
        this.onMenuClickListener = onMenuClickListener
    }
}